import React, { Component } from 'react'
import { Button, Text, TextInput, View } from 'react-native'

export default class UserAddor extends Component {
    state={user:{}}
    _add=()=>{
        //todo
        this.props.onUserAdd(this.state.user)
    }
    _unameChange=uname=>{
        let user=this.state.user
        user.uname=uname
        this.setState({user})
    }
    _addressChange=address=>{
        let user=this.state.user
        user.address=address
        this.setState({user})
    }
    render() {
        return (
            <View>
                <TextInput value={this.state.user.uname} onChangeText={this._unameChange}/>
                <TextInput value={this.state.user.address} onChangeText={this._addressChange}/>
                <Button title="添加" onPress={this._add}/>
            </View>
        )
    }
}
